<template>
<div>
  <el-table style="width: 100%" :data="nav">
      <el-table-column
        prop="title"
        label="标题"
        width="180">
      </el-table-column>
      <el-table-column
        prop="body"
        label="内容"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
      <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button @click="Edit(scope.row._id)" type="text" size="small">编辑</el-button>
        <el-button @click="remove(scope.row._id)" type="text" size="small">删除</el-button>
      </template>
    </el-table-column>
    </el-table>
</div>
</template>

<script>
  export default {
    data() {
      return {
       nav:[]
      }
    },
    methods:{
      fetce(){
        this.$http.get('/bodylists').then(res=>{
          this.nav=res.data
        })
      },
      Edit(id){
        this.$router.push(`/articles/${id}/edit`)
      },
      remove(id){
        this.$http.delete(`/articles/${id}`).then(res=>{
          this.$message({
                    message: '删除文章成功',
                    type: 'success'
                    })
          this.fetce()
        })
      }
    },
    created(){
      this.fetce()
    }
  }
</script>